#ifndef _SCENE_H_
#define _SCENE_H_

#include <string>
#include <boost/property_tree/ptree.hpp>

#include "include/GlobalGameObj.h"

using namespace std;
using namespace boost::property_tree;

class Scene
{
public:
    static int tolerance_distence;
	static int total_tolerance;

	enum SceneObjType
	{
		SceneObjCharacter,
		SceneObjTransporter,
		SceneObjNpc,
		SceneObjMonster,
	};

	struct SceneInfo
	{
		string scene_id;
		int scene_type;
		string scene_name;
		int res_id;
		int max_x;
		int max_y;
		string entry_str;
		string exit_str;
		string npc_str;
		string monster_str;
	};

	struct ExitInfo
	{
		int exit_id;
		int x;
		int y;
		string exit_name;
		int res_id;
		int dst_scene_id;
	};

	struct NpcInfo
	{
		int npc_id;
		int x;
		int y;
		string npc_name;
		int res_id;
	};

	struct MonsterInfo
	{
		int monster_id;
		int x;
		int y;
		string monster_name;
		int res_id;
	};

	struct SceneObj
	{
		string scene_id;
		int obj_type;
		int obj_id;
		int obj_res_id;
		int scene_type;
		int speed;
		int x;
		int y;
		int is_moving;
		string last_time;
		int start_x;
		int start_y;
		int end_x;
		int end_y;
		string arrive_time;
		int move_tolerance;
	};

    static string GetSceneObjKey(string scene_id, int type, int id);
	static int GetEntryPos(string & pos_str, int & x, int & y);
	static void GetExitInfo(string &exit_str, vector<ExitInfo *> & exit_info_list);
	static void GetNpcInfo(string &npc_str, vector<NpcInfo *> & npc_info_list);
	static void GetMonsterInfo(string &monster_str, vector<MonsterInfo *> & monster_info_list);
	static void GetSceneInfo(GlobalGameObj *p_game_obj, string scene_id, SceneInfo *p_scene_info);
	static void GetSceneInfoTree(GlobalGameObj *p_game_obj, string scene_id, ptree &scene_tree);
	static void AddSceneObj(GlobalGameObj *p_game_obj, SceneObj *p_scene_obj);
	static void GetSceneObj(GlobalGameObj *p_game_obj, SceneObj *p_scene_obj);
	static void GetSceneObjTree(GlobalGameObj *p_game_obj, SceneObj *p_scene_obj, ptree &scene_obj_tree);
	static void UpdateScenePlayer(GlobalGameObj *p_game_obj, string scene_id);
	static void GetScenePlayer(GlobalGameObj *p_game_obj, string scene_id, vector<int> &player_list, vector<int> &character_list);
    static int CanMove(string scene_id, string dest_scene_id);
private:
	static void SceneObj2Str(SceneObj *p_scene_obj, string &value);
	static void Str2SceneObj(string &value, SceneObj *p_scene_obj);
	static void CalculatePosition(SceneObj *p_scene_obj);
};

#endif
